home *** CD-ROM | disk | FTP | other *** search
- // Copyright (c)1995 Ray Dream, Inc. All Rights Reserved.
- /* $Id: Rainbow.cpp 1.3 1997/04/05 02:41:56 damien Exp $ */
- //
- // Implementation of the Rainbow Shader
- //
-
-
- #ifndef __RAINBOW__
- #include "Rainbow.h"
- #endif
-
- #undef INTERFACE
- #define INTERFACE RainbowShader
-
- // Rainbow Constructor :
- RainbowShader::RainbowShader() {
- RainbowPublicData.fIntensity = 100; // Default Value of the rainbow's intensity (100%)
- RainbowPublicData.fModeLocalOrGlobal = 1 ; // Default is Local (0 : Global)
- };
-
- RainbowShader::~RainbowShader() {
- global_count_Obj--; // used by the DLL to know if it can be unloaded
- // the variable is global and defines in "Shadrdll.cpp"
- }
-
- // How to Clone the Rainbow
- I3DExtension* RainbowShader::Clone(THIS) {
- RainbowShader* theClone = new RainbowShader; // Create New Rainbow
- CopyData(theClone); // Copy Data in the new Rainbow
- theClone->AddRef();
- return theClone;
- }
-
- short RainbowShader::GetResID(THIS) {
- return 129; // Ressource ID for the Shell
- }
-
- // Give a pointer to the public data that the shell can modify
- void* RainbowShader::GetExtensionDataBuffer(THIS) {
- return ((void*) &(RainbowPublicData));
- }
-
- // Compare two Shader
- BOOLEAN RainbowShader::IsEqualTo(THIS_ I3DExShader* aShader) {
- return ((RainbowPublicData.fIntensity==((RainbowShader*)aShader)->RainbowPublicData.fIntensity)
- &&(RainbowPublicData.fModeLocalOrGlobal==((RainbowShader*)aShader)->RainbowPublicData.fModeLocalOrGlobal));
- }
-
-
- BOOLEAN RainbowShader::DependsOnAppliedExtent(THIS) {
- return FALSE; // The Rainbow doesn't use the UV Space but only the Normal Vectors
- }
-
- HRESULT RainbowShader::DoShade(THIS_ ShadingInOut* /*theShadingIO*/, ShadingElem* /*theShadingElem*/) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- ULONG RainbowShader::GetPreferredOutput(THIS) {
- return kUsesGetColor; // Tell the Shell that this Shader is a Color Shader
- }
-
- HRESULT RainbowShader::GetValue(THIS_ NUM3D* result, ShadingIn* theShadingIn, ShadingElem* theShadingElem) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- // This shader returns a Color defined by a Vector in the RGB Cube
- HRESULT RainbowShader::GetColor(THIS_ COLOR3D* result, ShadingIn* theShadingIn, ShadingElem* theShadingElem) {
- NUM3D temp=RainbowPublicData.fIntensity;
- temp/=100.0;
- result->Mode = 0; // RGB color mode
- if (RainbowPublicData.fModeLocalOrGlobal==1) {
- result->R = (((theShadingIn->fNormalLoc[0])*temp)/2)+0.5;
- result->G = (((theShadingIn->fNormalLoc[1])*temp)/2)+0.5;
- result->B = (((theShadingIn->fNormalLoc[2])*temp)/2)+0.5;
- }
- else {
- result->R = (((theShadingIn->fNormal[0])*temp)/2)+0.5;
- result->G = (((theShadingIn->fNormal[1])*temp)/2)+0.5;
- result->B = (((theShadingIn->fNormal[2])*temp)/2)+0.5;
- }
- return NOERROR;
- }
-
- HRESULT RainbowShader::GetVector(THIS_ VECTOR3D* result, ShadingIn* theShadingIn, ShadingElem* theShadingElem) {
- return ResultFromScode(E_NOTIMPL);
- }
-
- // Set the flags of the Shader
- HRESULT RainbowShader::GetShadingFlags(THIS_ ShadingFlags* theFlags) {
- theFlags->fNeedsNormalLoc = TRUE;
- theFlags->fNeedsNormal = TRUE;
- theFlags->fCallOnce = FALSE;
- return NOERROR;
- }
-
- // Function to Clone the Object
- void RainbowShader::CopyData(COMShader* dest) {
- COMShader::CopyData(dest); // Copy Data of the inherited object (Shader)
- ((RainbowShader*)dest)->RainbowPublicData=RainbowPublicData; // Copy Public Data
- }
-
- // If you don't use a resource that can give the type of the different
- // data in the CheckerShaderPublicData you have to give a pointer on this
- // Properties Map
- ExtensionDataMap* RainbowShader::GetExtensionDataMap(THIS) {
- return NULL;
- }
-
-